
	
/*
 * 自动计算表单数据
 */
function calFormItem() {
	
    var domForm = $('#' + window.formObj.c.id_form);
	var exchangeRate = parseFloat(domForm.find('input[name="exchangeRate"]').val()); // 计算汇率
	if (isNaN(exchangeRate) || exchangeRate == null || exchangeRate == '' || exchangeRate == undefined){
		exchangeRate = 0;
		domForm.find('input[name="exchangeRate"]').val(exchangeRate);
	}
	
	var sonlist = formObj.c.subGridObj.c.sonlist;
	for (var i = 0; i < sonlist.length; i++) {
		formObj.c.subGridObj.c.sonlist[i]['amountCny'] = exchangeRate ? Math.round((sonlist[i].amount) * exchangeRate * 100) / 100 : 0
	}
	formObj.c.subGridObj.reloadGrid();
	
	// 计算付款外币总金额、付款CNY总金额
	var amountTotalLocal = 0;
	var amountTotalCny = 0;
	for (var i = 0; i < sonlist.length; i++) {
		var amount = parseFloat(sonlist[i]['amount']);
		if(amount) {
			amountTotalLocal = amountTotalLocal + amount;
			amountTotalCny = amountTotalCny + amount * exchangeRate;
		}
	}
	domForm.find('input[name="amountTotalLocal"]').val(amountTotalLocal);
	domForm.find('input[name="amountTotalCny"]').val(Math.round(amountTotalCny * 100) / 100.00);

}